<template>
  <div>

    <el-container>
      <!--侧边栏-->
      <el-aside :width="asideWidth" style="min-height: 100vh;background-color: #001529"> <!--最小高度为整个界面的高度-->
        <div style="height: 60px;
            color: white;
            display: flex;
            align-items: center;
            justify-content: center;">
          <!--
          display: flex;  /*元素设置为 Flexbox 布局*/
          align-items: center;  /*垂直居中*/
          justify-content: center;" /*水平居中*/
          /*这三个属性通常一起使用，以在 Flexbox 容器中将子元素水平和垂直居中对齐。*/
          -->
          <img alt="" src="@/assets/logo1.png" style="width: 40px ; height: 40px">
          <span v-show="!isCollapse" class="logoTitle">YinLang</span>
        </div>
        <!--router可以切换路由-->
        <!--collapse控制收缩-->
        <!--collapse-transition动画开关-->
        <el-menu :collapse="isCollapse" :collapse-transition="false" :default-active="$route.path"
                 :router="true"
                 active-text-color="#ffffff" router
                 style="border: none;background-color: #001529;" text-color="rgba(255,255,255,0.65)">  <!--隐藏边框-->
          <!--当前激活菜单的index-->
          <!--:default-active="$route.path"配合菜单里面的index可以实现菜单高亮-->
          <el-menu-item index="/">  <!--一级菜单-->
            <!--设置菜单项的标题-->
            <!--标题是由一个图标 <i class="el-icon-house"></i> 和文本 <span>系统首页</span> 组成的-->
            <i class="el-icon-house"></i>
            <span slot="title">系统首页</span>

          </el-menu-item>
          <el-menu-item>
            <i class="el-icon-cpu"></i>
            <span slot="title">导航1</span>
          </el-menu-item>
          <el-menu-item>
            <i class="el-icon-cpu"></i>
            <span slot="title">导航2</span>
          </el-menu-item>

          <el-submenu index="">  <!--一个下拉子菜单-->
            <!--子菜单的标题也是由一个图标 <i class="el-icon-menu"></i> 和文本 <span>信息管理</span> 组成的-->
            <template slot="title">
              <i class="el-icon-menu"></i>
              <span>信息管理</span>
            </template>
            <el-menu-item index="/users">用户管理</el-menu-item><!--下拉菜单中有一个 "用户管理" 的选项-->
            <el-menu-item>服务管理</el-menu-item>
          </el-submenu>

        </el-menu>
      </el-aside>

      <el-container>
        <!--头部区域-->
        <el-header>
          <i :class="collapseIcon" style="font-size: 26px" @click="handleCollapse"></i>
          <el-breadcrumb separator-class="el-icon-arrow-right" style="margin-left: 20px">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item :to="{ path: '/users' }">用户管理</el-breadcrumb-item>
          </el-breadcrumb>

          <div style="flex: 1; width: 0; display: flex; align-items: center; justify-content: flex-end">
            <el-dropdown placement="bottom">
              <div style="display: flex; align-items: center;cursor: default">
                <i class="el-icon-quanping" style="font-size: 26px" @click="handFulls"></i>
                <img alt="" src="../assets/logo1.png" style="width: 40px; height: 40px;margin: 0 5px">
                <span>管理员</span>
              </div>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item>个人信息</el-dropdown-item>
                <el-dropdown-item>修改密码</el-dropdown-item>
                <el-dropdown-item>退出登录</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </div>
        </el-header>

        <!--主体区域-->
        <el-main style="background-color: #1890ff">

          <el-table
              :data="tableData"
              border
              style="">
            <el-table-column
                prop="date"
                label="日期"
                width="180">
            </el-table-column>
            <el-table-column
                prop="name"
                label="姓名"
                width="180">
            </el-table-column>
            <el-table-column
                prop="address"
                label="地址">
            </el-table-column>
          </el-table>


        </el-main>
      </el-container>
    </el-container>


  </div>
</template>
<script>
import axios from "axios";
import UsersView from "@/view/UsersView.vue";

export default {
  name: 'HomeView',
  components: {UsersView},
  data() {
    return {
      isCollapse: false, //默认false，不收缩
      asideWidth: '200px',
      collapseIcon: 'el-icon-s-fold',
      tableData: [{
        date: '2016-05-02',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }, {
        date: '2016-05-04',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1517 弄'
      }, {
        date: '2016-05-01',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1519 弄'
      }, {
        date: '2016-05-03',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1516 弄'
      }]
    }
  },
  methods: {
    handleCollapse() {
      this.isCollapse = !this.isCollapse
      this.asideWidth = this.isCollapse ? '64px' : '200px'
      this.collapseIcon = this.isCollapse ? 'el-icon-s-unfold' : 'el-icon-s-fold'
    },
    handFulls() {
      /*全屏*/
      document.documentElement.requestFullscreen()
    }
  }
}
</script>
<style scoped>
.el-menu--inline {
  background-color: #000c17 !important;
}

.el-menu--inline .el-menu-item {
  background-color: #000c17 !important; /*!important强制生效样式*/
  padding-left: 49px !important;
}

.el-menu--inline .el-menu-item:hover {
  border-radius: 5px !important;
  background-color: #000c17 !important; /*!important强制生效样式*/
}

.el-menu-item:hover, .el-submenu__title:hover { /*:hover鼠标移入之后发生的变化*/
  border-radius: 5px !important;
  color: #fff !important;
  background-color: #1890ff !important;
}

.el-submenu__title:hover i {
  border-radius: 5px !important;
  color: #fff !important;
}

.el-menu-item.is-active {
  background-color: #40a9ff !important;
  border-radius: 5px !important;
  width: calc(100% - 8px);
  margin-left: 4px;
}

.el-menu-item.is-active i, .el-menu-item.is-active .el-tooltip {
  margin-left: -4px;
}

.el-menu-item {
  height: 40px !important;
  line-height: 40px !important;
}

.el-submenu__title {
  height: 40px !important;
  line-height: 40px !important;
}

.el-submenu .el-menu-item {
  min-width: 0px !important;
}

.el-menu--inline .el-menu-item.is-active {
  padding-left: 45px !important;
}

.el-aside {
  /*动画效果*/
  transition: width .3s;
  /*边缘阴影*/
  box-shadow: 2px 0 6px rgba(0, 21, 41, .35);
}

.logoTitle {
  margin-left: 5px;
  font-size: 20px;
  /*动画效果*/
  transition: all .3s;
}

.el-header {
  box-shadow: 2px 0 6px rgba(0, 21, 41, .35);
  display: flex;
  /*居中*/
  align-items: center;
}


</style>